package com.ericsson.rm.dao;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.ericsson.rm.model.ProjectDetail;
import com.ericsson.rm.vo.ProjectDetailsVO;

@Repository
public class ProjectDetailDaoImpl implements ProjectDetailDao {
	
	
	@PersistenceContext
	EntityManager entityManager;

	@Override
	@Transactional(propagation=Propagation.REQUIRES_NEW)
	public void saveProjectDtlToDB(ProjectDetailsVO vo){
		ProjectDetail  details = new ProjectDetail();
		try{
		details.setNoOfResource(vo.getNo_of_resource());
		details.setProjectName(vo.getProjectName());
		details.setRegion(vo.getRegion());
		details.setProjectEndDate(vo.getProject_end_date());
		details.setProjectStartDate(vo.getProject_start_date());
		details.setProjectId(vo.getProjectId());
		details.setStatus(vo.getStatus());
	
		entityManager.persist(details);
		entityManager.flush();
		entityManager.close();
		}
		
		catch(Exception e){
			e.printStackTrace();
		}
	}

}
